<?php
$periodM = ($periodM)?$periodM:array();
$semaine = ($semaine)?$semaine:array();
?>
<div class="content-head">
    <h3>Écran de sélection du périmètre</h3>
</div>
<div class="content-body">
    <form id="op-form" action="<?php //echo $this->url('operation/default', array('controller'=>'tableaudebord')) ?>" method="post">
    <div class="periodeBox">
        <table width="100%">
            <tr>
                <td class="tdLeft">Période</td>
                <td class="tdRight">
                    <table class="tRight">
                        <tr>
                            <?php for($y=date('Y');$y>2011;$y--): 
                            if($periodY) {
                                if(in_array($y, $periodY)){
                                    $checked = 'checked="checked"';
                                } else {
                                    $checked = '';
                                }
                            } else {
                                $checked = ($y==date('Y'))?'checked="checked"':'';   
                            }
                            ?>
                            <td><label>
                                <input type="checkbox" name="periodY[]" value="<?php echo $y; ?>" class="styled" <?php echo $checked; ?> /> <?php echo $y; ?>
                            </label></td>
                            <?php endfor; ?>
                        </tr>
                        <tr>
                            <td><label><input type="checkbox" name="periodM[]" value="1" class="styled" <?php echo (in_array(1, $periodM))?'checked="checked"':''; ?> /> Jan</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="2" class="styled" <?php echo (in_array(2, $periodM))?'checked="checked"':''; ?> /> Fév</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="3" class="styled" <?php echo (in_array(3, $periodM))?'checked="checked"':''; ?> /> Mar</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="4" class="styled" <?php echo (in_array(4, $periodM))?'checked="checked"':''; ?> /> Avr</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="5" class="styled" <?php echo (in_array(5, $periodM))?'checked="checked"':''; ?> /> Mai</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="6" class="styled" <?php echo (in_array(6, $periodM))?'checked="checked"':''; ?> /> Juin</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="7" class="styled" <?php echo (in_array(7, $periodM))?'checked="checked"':''; ?> /> Juil</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="8" class="styled" <?php echo (in_array(8, $periodM))?'checked="checked"':''; ?> /> Août</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="9" class="styled" <?php echo (in_array(9, $periodM))?'checked="checked"':''; ?> /> Sept</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="10" class="styled" <?php echo (in_array(10, $periodM))?'checked="checked"':''; ?> /> Oct</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="11" class="styled" <?php echo (in_array(11, $periodM))?'checked="checked"':''; ?> /> Nov</label></td>
                            <td><label><input type="checkbox" name="periodM[]" value="12" class="styled" <?php echo (in_array(12, $periodM))?'checked="checked"':''; ?> /> Déc</label></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <div class="semaineBox">
        <table width="100%">
            <tr>
                <td class="tdLeft">Semaine</td>
                <td class="tdRight">
                    <table class="tRight">                        
                        <tr>
                            <td><label><input type="checkbox" name="semaine[]" value="1" class="styled" id="l1" <?php echo (in_array(1, $semaine))?'checked="checked"':''; ?> /> Lun</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="2" class="styled" id="l2" <?php echo (in_array(2, $semaine))?'checked="checked"':''; ?> /> Mar</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="3" class="styled" id="l3" <?php echo (in_array(3, $semaine))?'checked="checked"':''; ?> /> Mer</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="4" class="styled" id="l4" <?php echo (in_array(4, $semaine))?'checked="checked"':''; ?> /> Jeu</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="5" class="styled" id="l5" <?php echo (in_array(5, $semaine))?'checked="checked"':''; ?> /> Ven</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="6" class="styled" id="l6" <?php echo (in_array(6, $semaine))?'checked="checked"':''; ?> /> Sam</label></td>
                            <td><label><input type="checkbox" name="semaine[]" value="0" class="styled" id="l7" <?php echo (in_array(0, $semaine))?'checked="checked"':''; ?> /> Dim</label></td>                            
                        </tr>
                        <tr>
                            <td colspan="7">ou saisir date spécifique <input type="text" name="specific_date" class="datepicker" /><input type="hidden" name="altDate" id="altDate" /></td>                            
                        </tr>
                    </table>
                </td>
                <td><label><input type="checkbox" name="all-semaine" class="styled" id="decochetout"/> <i>Tout décocher</i></label></td>
            </tr>
        </table>
    </div>
    <div id="rubrique">
        <input type="radio" id="radio1" name="rubrique" value="1" checked="checked" /><label for="radio1">Tableau de bord</label>
        <input type="radio" id="radio2" name="rubrique" value="2" /><label for="radio2">Synthèse</label>
        <input type="radio" id="radio3" name="rubrique" value="3" /><label for="radio3">Budget</label>
    </div>
    <div class="operationBox">
        <table align="center">
            <tr>
                <td align="right">
                    <div class="select-wrapper">
                        <p>Périmètre</p>
                        <select class="choosebox" name="selos" id="selos" size="15" onChange="listbox_moveselected('selos', 'boutiques')" style="width: 20em;">
                            <?php foreach ($stores as $store) : ?>
                            <option value="<?php echo $store->idStore;?>"><?php echo $this->escapeHtml($store->name);?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </td>
                
                <td align="center" width="70"></td>
                
                <td align="left">
                    <div class="select-wrapper">
                        <p>Périmètre sélectionné</p>
                        <select class="choosebox" name="boutiques" id="boutiques" size="15" multiple="multiple" style="width: 20em;"></select>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="3" class="center padTop20">
                    <input class="button" type="button" name="valid" value="Valider" onclick="submitForm();" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>